var __extends =
    (this && this.__extends) ||
    (function () {
      var e = function (t, a) {
        return (e =
          Object.setPrototypeOf ||
          ({ __proto__: [] } instanceof Array &&
            function (e, t) {
              e.__proto__ = t;
            }) ||
          function (e, t) {
            for (var a in t)
              Object.prototype.hasOwnProperty.call(t, a) && (e[a] = t[a]);
          })(t, a);
      };
      return function (t, a) {
        function i() {
          this.constructor = t;
        }
        if ("function" != typeof a && null !== a)
          throw new TypeError(
            "Class extends value " + String(a) + " is not a constructor or null"
          );
        e(t, a),
          (t.prototype =
            null === a
              ? Object.create(a)
              : ((i.prototype = a.prototype), new i()));
      };
    })(),
  AXSquareView = (function (e) {
    function t() {
      var t = e.call(this) || this;
      return (
        (t.onLoadCurrentPhysicalpowerDataFn = {
          caller: t,
          code: 1331,
          method: function (e) {
            if (0 == e.code) {
              (t.label_todayLoginTime.text = t.timeStamp(e.data.minute)),
                (t.label_currentTiLiZhi.text =
                  e.data.residue + " / " + e.data.max),
                (t.label_kelingtilizhi.text = e.data.tlz + " 点"),
                (t.label_skillPersonNum.text = "已杀 " + e.data.pk + " 人"),
                (t.label_fight_totalNum.text = e.data.fc + "次");
              var a = parseInt(e.data.today);
              0 == a
                ? ((t.btn_getPower.label = "领取"),
                  (t.btn_getPower.gray = !1),
                  (t.btn_getPower.disabled = !1),
                  t.btn_getPower.on(
                    Laya.Event.CLICK,
                    t,
                    t.onDidClickGetPowerAction
                  ))
                : a > 0 && a < 5
                ? ((t.btn_getPower.label = "5点后领取"),
                  t.btn_getPower.on(
                    Laya.Event.CLICK,
                    t,
                    t.onDidClickGetPowerAction1
                  ))
                : a >= 5 &&
                  ((t.btn_getPower.label = "已领取"),
                  (t.btn_getPower.gray = !0),
                  (t.btn_getPower.disabled = !0),
                  t.btn_getPower.on(
                    Laya.Event.CLICK,
                    t,
                    t.onDidClickGetPowerAction1
                  )),
                (t.lingqu = e.data.sinew),
                -1 == e.data.sinew
                  ? ((t.btn_give_tili.label = "未开启"),
                    (t.btn_give_tili.gray = !0),
                    (t.btn_give_tili.disabled = !0))
                  : 0 == e.data.sinew
                  ? ((t.btn_give_tili.label = "领取"),
                    (t.btn_give_tili.gray = !1),
                    (t.btn_give_tili.disabled = !1))
                  : 1 == e.data.sinew &&
                    ((t.btn_give_tili.label = "已领取"),
                    (t.btn_give_tili.gray = !0),
                    (t.btn_give_tili.disabled = !0)),
                e.data.happy && 1 == e.data.happy
                  ? (t.btn_yulechang.visible = !0)
                  : (t.btn_yulechang.visible = !1),
                t.dealCurrentDate();
            }
          },
        }),
        (t.onLoadgetPowerDataFn = {
          caller: t,
          code: 1374,
          method: function (e) {
            0 != e.code
              ? ToastView.toastView(e.msg)
              : (ToastView.toastView(e.msg),
                WebSocketService.send({ c: 1331, d: null }),
                Laya.stage.event("GameMainView", "exp"),
                Laya.stage.event("HomePageView", "exp"));
          },
        }),
        t.btn_square_back.on(Laya.Event.CLICK, t, t.onPreSquareBack),
        t.btn_yulechang.on(Laya.Event.CLICK, t, t.onYuLeChangFn),
        t.btn_kongmiao.on(Laya.Event.CLICK, t, t.onKongMiaoDidClick),
        t.btn_zhaoxianguan.on(Laya.Event.CLICK, t, t.onZhaoXianGuanDidClick),
        t.btn_taoyuan.on(Laya.Event.CLICK, t, t.onTaoYuanActionDidClick),
        t.btn_taixueyuan.on(Laya.Event.CLICK, t, t.onTaiXueYuanDidClick),
        t.btn_xunlianchang.on(Laya.Event.CLICK, t, t.onXunLianChangDidClick),
        t.btn_shengxingtai.on(Laya.Event.CLICK, t, t.onShengXingDidClick),
        t.btn_qianzhuang.on(Laya.Event.CLICK, t, t.onButtonDidClick),
        t.btn_majiu.on(Laya.Event.CLICK, t, t.onButtonDidClick),
        t.btn_fangchan.on(Laya.Event.CLICK, t, t.onButtonDidClick),
        t.btn_give_tili.on(
          Laya.Event.CLICK,
          t,
          t.onDidClickGetPowerActionGetItem
        ),
        WebSocketService.addListener({
          caller: t,
          code: 1375,
          method: t.onLoadJIanTingLingQuTiLiData,
        }),
        WebSocketService.addListener(t.onLoadCurrentPhysicalpowerDataFn),
        WebSocketService.addListener(t.onLoadgetPowerDataFn),
        t
      );
    }
    return (
      __extends(t, e),
      (t.openView = function () {
        return (
          null == this.squareVC && (this.squareVC = new t()),
          WebSocketService.send({ c: 1331, d: null }),
          (this.squareVC.btn_yulechang.visible = !1),
          this.squareVC
        );
      }),
      (t.prototype.onYuLeChangFn = function () {
        if (Global.roleLvl >= 30 || Global.roleVip >= 3 || Global.superHK > 0) {
          Laya.loader.retryNum = 2;
          var e = [
            { url: "res/atlas/comp.atlas", type: Laya.Loader.ATLAS },
            { url: "res/atlas/comp/happy.atlas", type: Laya.Loader.ATLAS },
            { url: "res/atlas/comp/commonpic.atlas", type: Laya.Loader.ATLAS },
          ];
          Laya.loader.load(
            e,
            Laya.Handler.create(this, this.OnLoadedRecourse),
            Laya.Handler.create(
              AXProgressBarView,
              AXProgressBarView.onLoadedRecourse,
              null,
              !1
            )
          );
        } else ToastView.toastView("需要达到30级或VIP3或开通超级壕客进入");
      }),
      (t.prototype.onTaoYuanActionDidClick = function () {
        var e = AXTaoYuanPageView.showTaoYuanPageView();
        e.pos(0, 0), Laya.stage.addChild(e);
      }),
      (t.prototype.onButtonDidClick = function (e) {
        var t = e.target.name;
        if ("item_yiguan" == t) {
          var a = MedicalView.openMedicalView();
          (a.y = 70), Laya.stage.addChild(a);
        } else if ("item_qianzhuang" == t) {
          var i = MoneyBankView.openView();
          (i.y = 35), Laya.stage.addChild(i);
        } else if ("item_majiu" == t) {
          var n = MountsMainController.showMountsMainView();
          (n.y = 35), Laya.stage.addChild(n);
        } else if ("item_zhanchang" == t) {
          var o = [
            { url: "res/atlas/comp.atlas", type: Laya.Loader.ATLAS },
            {
              url: "res/atlas/comp/battlefield.atlas",
              type: Laya.Loader.ATLAS,
            },
            { url: "res/atlas/fight.atlas", type: Laya.Loader.ATLAS },
          ];
          Laya.loader.load(
            o,
            Laya.Handler.create(this, function () {
              var e = battlefield.showBattleView();
              e.pos(0, 35), Laya.stage.addChild(e);
            }),
            Laya.Handler.create(
              AXProgressBarView,
              AXProgressBarView.onLoadedRecourse,
              null,
              !1
            )
          );
        } else if ("item_fangchan" == t) {
          var l = EstateHomeView.showEstateHomeView(!0);
          l.pos(0, 70), Laya.stage.addChild(l);
        }
      }),
      (t.prototype.onTaiXueYuanDidClick = function () {
        var e = AXEducationalView.openView();
        e.pos(0, 35), Laya.stage.addChild(e);
      }),
      (t.prototype.onKongMiaoDidClick = function () {
        var e = AXConfuciusInstituteView.openView();
        e.pos(0, 35), Laya.stage.addChild(e);
      }),
      (t.prototype.onZhaoXianGuanDidClick = function () {
        var e = AXTalentPoolView.openView();
        e.pos(0, 35), Laya.stage.addChild(e);
      }),
      (t.prototype.onXunLianChangDidClick = function () {
        var e = AXTrainingHallView.openView();
        e.pos(0, 35), Laya.stage.addChild(e);
      }),
      (t.prototype.OnLoadedRecourse = function () {
        var e = AXEnjoyPlaceView.openView();
        e.pos(0, 35), Laya.stage.addChild(e);
      }),
      (t.prototype.dealCurrentDate = function () {
        var e = new Date().getHours();
        e > 13 && e < 17
          ? (this.label_give_time.text = "下次领取时间 17:00 - 19:00")
          : e > 18 && e < 21
          ? (this.label_give_time.text = "下次领取时间 21:00 - 23:00")
          : e > 24 || e < 17
          ? (this.label_give_time.text = "下次领取时间 12:00 - 14:00")
          : e >= 17 && e <= 19
          ? ((this.label_give_time.text = "17:00 - 19:00 可领取"),
            1 == this.lingqu &&
              (this.label_give_time.text = "下次领取时间 21:00 - 23:00"))
          : e >= 21 && e <= 23
          ? ((this.label_give_time.text = "21:00 - 23:00 可领取"),
            1 == this.lingqu &&
              (this.label_give_time.text = "下次领取时间 12:00 - 14:00"))
          : e >= 12 && e <= 14
          ? ((this.label_give_time.text = "12:00 - 14:00 可领取"),
            1 == this.lingqu &&
              (this.label_give_time.text = "下次领取时间 17:00 - 19:00"))
          : (this.label_give_time.text = "");
      }),
      (t.prototype.onDidClickGetPowerActionGetItem = function () {
        WebSocketService.send({ c: 1375, d: null });
      }),
      (t.prototype.onLoadJIanTingLingQuTiLiData = function (e) {
        ToastView.toastView(e.msg),
          WebSocketService.send({ c: 1331, d: null }),
          Laya.stage.event("GameMainView", "exp"),
          Laya.stage.event("HomePageView", "exp");
      }),
      (t.prototype.timeStamp = function (e) {
        var t = Math.floor(e / 60);
        return (
          console.log(t),
          t > 0
            ? t + "小时" + (e - 60 * Math.floor(e / 60) + "分钟")
            : e + "分钟"
        );
      }),
      (t.prototype.onDidClickGetPowerAction = function () {
        WebSocketService.send({ c: 1374, d: null });
      }),
      (t.prototype.onDidClickGetPowerAction1 = function (e) {
        "已领取" == e.target.label
          ? ToastView.toastView("您已领取体力值")
          : ToastView.toastView("请在5点以后来领取今日体力值");
      }),
      (t.prototype.onShengXingDidClick = function () {
        var e = AXRisingStarView.showRisingStarView();
        e.pos(0, 35), Laya.stage.addChild(e);
      }),
      (t.prototype.onPreSquareBack = function () {
        this.removeSelf();
      }),
      t
    );
  })(ui.SquareController.AXSquareViewUI);
